package cn.cj.erp.modules.login.controller;

import cn.cj.erp.common.vo.login.CaptchaResponseVo;
import cn.cj.erp.modules.common.controller.AbstractController;
import cn.cj.erp.common.enums.CaptchaTypeEnum;
import cn.cj.erp.common.http.Result;
import cn.cj.erp.service.CaptureService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 验证码操作处理
 *
 * @author jianchen
 */
@Slf4j
@RestController
public class CaptchaController extends AbstractController {
    @Resource
    private CaptureService captureService;

    /**
     * 生成验证码
     */
    @GetMapping("/captcha")
    public Result<CaptchaResponseVo> getCode(CaptchaTypeEnum captchaType) {
        if (captchaType == null) {
            captchaType = CaptchaTypeEnum.MATH;
        }
        return Result.ok(captureService.getCaptureCode(captchaType));
    }
}
